<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core" 
  xmlns:p="http://primefaces.org/ui" 
  xmlns:h="http://java.sun.com/jsf/html" 
  xmlns:pr="http://java.sun.com/jsf/composite/totororo"
  template="../template_back.xhtml">
  <ui:define name="content">
     <h:form>
    <p:dataTable id="dataTable" var="b" value="#{bookController.books}" paginator="true" rows="5">
        <f:facet name="header"> Liste des livres </f:facet>
        <p:column headerText="Illustration">        	
		  	<div class="book-image">		  	
				<pr:photo type="book" elementId="#{b.id}" size="small"/>
			</div>
        </p:column>
        <p:column sortBy="#{b.title}" headerText="Title">
            <h:outputText value="#{b.title}"/>
        </p:column>

        
        <p:column headerText="Auteur">
        <ui:repeat value="#{b.authors}" var="loc">
            <h:outputText value="#{loc.lastName} #{loc.firstName} "/>
            <br/>
         </ui:repeat>
        </p:column>
         
                       
        <p:column headerText="Category">
            <h:outputText value="#{b.category.title}"/>
        </p:column>
        
        <p:column headerText="Prix">
            <h:outputText value="#{b.price}"/>
        </p:column>

		<p:column headerText="Editer">
	    	<h:commandButton value="Edit" action="#{bookController.editer}">
	    		<f:param name="bookId" value="#{b.id}"/>
			</h:commandButton>
		</p:column>
		
        <p:column headerText="Delete">
			 <h:commandButton action="#{bookController.delete}" value="Supprimer">
			 	<f:param name="bookId" value="#{b.id}"/>
			 </h:commandButton>
        </p:column>    
    
    
    </p:dataTable>
    <p:commandButton value="Ajouter un livre" action="#{bookController.addNewBook}"/>
    
   	</h:form> 
                     
  </ui:define>
</ui:composition>
